﻿<%@ Page Title="" Language="C#" Inherits="System.Web.Mvc.ViewPage<dynamic>" %>

<%@ Import Namespace="DoAnPhatTrienPhanMem.Controllers" %>
<%@ Import Namespace="DoAnPhatTrienPhanMem.Models" %>
<%@ Import Namespace="DoAnPhatTrienPhanMem.Constants" %>
<%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
    <script src="/Scripts/CommonFunction.js" type="text/javascript"></script>
    <script src="/Scripts/Constant.js" type="text/javascript"></script>
    <link href="/Content/MainStyle.css" rel="stylesheet" type="text/css" />
    <script runat="server">
        private void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                var ID = "";
                if (ViewData.ContainsKey("ID")) ID = ViewData["ID"].ToString();
                Ext.Net.MenuItem node;
                node = new Ext.Net.MenuItem { Text = "Lưu thông tin" };
                if (!String.IsNullOrEmpty(ID.ToString()))
                {
                    node.Listeners.Click.Handler = "CommonFunction.submitnreview('', 'CanBo','Details', {ID: '" + ID + "'});";
                }
                else node.Listeners.Click.Handler = "CommonFunction.submitnreview('', 'CanBo','Index','');";
                MainMenu.Menu.Add(node);

                var user = "";
                if (Session[Constants.SessionName.UserName] != null) user = Session[Constants.SessionName.UserName].ToString();
                if (!String.IsNullOrEmpty(user))
                {
                    frmLogin.Hidden = true;
                    btnLogin.Hidden = true;
                    UserID.Text = user;
                    //UserID.NavigateUrl = "#";
                    UserID.Hidden = false;
                    afterLogin.Hidden = false;
                    var AccountCtrl = new AccountController();
                    var MaCB = AccountCtrl.GetByUserName(user).MaCB;
                    if (MaCB != null)
                    {
                        var CanBoCtrl = new CanBoController();
                        var IDcb = CanBoCtrl.GetSoYeuCanBoByMaCB(MaCB.ToString()).ID;
                        UserID.Listeners.Click.Handler = "CommonFunction.loadPage('CanBo','Details',{ID: '" + IDcb + "'});";
                    }
                }
            }
        }
    </script>
    <script type="text/javascript">
        function loadForm(store, records) {
            if (records.length > 0) {
                window.HoTen.setValue(records[0].data.HoTen);
                window.NgaySinh.setValue(records[0].data.NgaySinh);
                window.NoiSinh.setValue(records[0].data.NoiSinh);
                window.GioiTinh.setValue(records[0].data.GioiTinh);
                window.DiaChi.setValue(records[0].data.DiaChi);
                window.QueQuan.setValue(records[0].data.QueQuan);
                window.SoDienThoai.setValue(records[0].data.SoDienThoai);
                window.DanToc.setValue(records[0].data.DanToc);
                window.TonGiao.setValue(records[0].data.TonGiao);
                window.NgayVaoDang.setValue(records[0].data.NgayVaoDang);
                window.CMND.setValue(records[0].data.CMND);
                window.SoHieuCongChuc.setValue(records[0].data.SoHieuCongChuc);
                window.HocHam.setValue(records[0].data.HocHam);
                window.HocVi.setValue(records[0].data.HocVi);
                window.GhiChu.setValue(records[0].data.GhiChu);
            }
            else {
            }
        }
    </script>
</head>
<body id="bd" class="fs3">
    <ext:ResourceManager ID="ResourceManager1" runat="server" Locale="vi-VN" CleanResourceUrl="false" />
    <ext:Store ID="storeData" runat="server">
        <Proxy>
            <ext:HttpProxy Url="/CanBo/GetByID" />
        </Proxy>
        <Reader>
            <ext:JsonReader Root="data">
                <Fields>
                    <ext:RecordField Name="ID" />
                    <ext:RecordField Name="MaCB" />
                    <ext:RecordField Name="HoTen" />
                    <ext:RecordField Name="NgaySinh">
                        <Convert Fn="CommonFunction.renderDate" />
                    </ext:RecordField>
                    <ext:RecordField Name="NoiSinh" />
                    <ext:RecordField Name="GioiTinh" />
                    <ext:RecordField Name="DiaChi" />
                    <ext:RecordField Name="QueQuan" />
                    <ext:RecordField Name="SoDienThoai" />
                    <ext:RecordField Name="DanToc" />
                    <ext:RecordField Name="TonGiao" />
                    <ext:RecordField Name="NgayVaoDang">
                        <Convert Fn="CommonFunction.renderDate" />
                    </ext:RecordField>
                    <ext:RecordField Name="CMND" />
                    <ext:RecordField Name="SoHieuCongChuc" />
                    <ext:RecordField Name="HocHam" />
                    <ext:RecordField Name="HocVi" />
                    <ext:RecordField Name="GhiChu" />
                </Fields>
            </ext:JsonReader>
        </Reader>
        <BaseParams>
            <ext:Parameter Name="ID" Value="#{ID}.getValue()" Mode="Raw" />
        </BaseParams>
        <Listeners>
            <Load Fn="loadForm" />
        </Listeners>
    </ext:Store>
    <div id="ja-wrapper">
        <div id="ja-container" class="wrap clearfix">
            <div class="main">
                <div class="inner clearfix">
                    <div id="ja-mainbody">
                        <ext:Panel ID="Panel1" runat="server" Border="false" Header="false" AutoWidth="true"
                            AutoHeight="true">
                            <Items>
                                <ext:FormPanel runat="server" ID="frmMain" Border="false" Header="false" Layout="AnchorLayout"
                                    LabelWidth="150" Padding="10" Url="/CanBo/Save" Height="500">
                                    <Items>
                                        <ext:Hidden runat="server" ID="ID" Text='<%# ViewData["ID"] %>' AutoDataBind="true" />
                                        <ext:TextField runat="server" ID="HoTen" FieldLabel="Họ tên" AnchorHorizontal="70%"
                                            LabelSeparator="<font color=red>* </font>" AllowBlank="false" />
                                        <ext:DateField runat="server" ID="NgaySinh" FieldLabel="Ngày sinh" AnchorHorizontal="70%"
                                            LabelSeparator="<font color=red>* </font>" AllowBlank="false" />
                                        <ext:TextField runat="server" ID="NoiSinh" FieldLabel="Nơi sinh" AnchorHorizontal="70%"
                                            LabelSeparator="<font color=red>* </font>" AllowBlank="false" />
                                        <ext:ComboBox runat="server" ID="GioiTinh" FieldLabel="Giới tính" AnchorHorizontal="70%"
                                            SelectedIndex="0" LabelSeparator="<font color=red>* </font>" AllowBlank="false">
                                            <Items>
                                                <ext:ListItem Text="Nam" Value="NAM" />
                                                <ext:ListItem Text="Nữ" Value="NU" />
                                            </Items>
                                        </ext:ComboBox>
                                        <ext:TextField runat="server" ID="DiaChi" FieldLabel="Địa chỉ" AnchorHorizontal="70%"
                                            LabelSeparator="<font color=red>* </font>" AllowBlank="false" />
                                        <ext:TextField runat="server" ID="QueQuan" FieldLabel="Quê quán" AnchorHorizontal="70%"
                                            LabelSeparator="<font color=red>* </font>" AllowBlank="false" />
                                        <ext:TextField runat="server" ID="SoDienThoai" FieldLabel="Số điện thoại" AnchorHorizontal="70%"
                                            LabelSeparator="<font color=red>* </font>" AllowBlank="false" />
                                        <ext:TextField runat="server" ID="DanToc" FieldLabel="Dân tộc" AnchorHorizontal="70%"
                                            LabelSeparator="<font color=red>* </font>" AllowBlank="false" />
                                        <ext:TextField runat="server" ID="TonGiao" FieldLabel="Tôn giáo" AnchorHorizontal="70%" />
                                        <ext:DateField runat="server" ID="NgayVaoDang" FieldLabel="Ngày vào Đảng" AnchorHorizontal="70%" />
                                        <ext:TextField runat="server" ID="CMND" FieldLabel="CMND" AnchorHorizontal="70%"
                                            LabelSeparator="<font color=red>* </font>" AllowBlank="false" />
                                        <ext:TextField runat="server" ID="SoHieuCongChuc" FieldLabel="Số hiệu công chức"
                                            AnchorHorizontal="70%" LabelSeparator="<font color=red>* </font>" AllowBlank="false" />
                                        <ext:ComboBox runat="server" ID="HocHam" FieldLabel="Học hàm" AnchorHorizontal="70%">
                                            <Items>
                                                <ext:ListItem Text="Giáo sư" Value="GS" />
                                                <ext:ListItem Text="Phó giáo sư" Value="PGS" />
                                            </Items>
                                        </ext:ComboBox>
                                        <ext:ComboBox runat="server" ID="HocVi" FieldLabel="Học vị" AnchorHorizontal="70%">
                                            <Items>
                                                <ext:ListItem Text="Tiến sĩ khoa học" Value="TSKH" />
                                                <ext:ListItem Text="Tiến sĩ" Value="TS" />
                                                <ext:ListItem Text="Thạc sĩ" Value="THS" />
                                            </Items>
                                        </ext:ComboBox>
                                        <ext:TextArea runat="server" ID="GhiChu" FieldLabel="Ghi chú" AnchorHorizontal="70%"
                                            Height="50" />
                                    </Items>
                                </ext:FormPanel>
                            </Items>
                        </ext:Panel>
                    </div>
                    <div id="ja-colwrap">
                        <div class="ja-innerpad">
                            <div style="padding: 10px;">
                                <ext:CompositeField runat="server" ID="afterLogin" Hidden="true" LabelWidth="20">
                                    <Items>
                                        <ext:LinkButton runat="server" ID="UserID" />
                                        <ext:LinkButton ID="LinkButton1" runat="server" Text="(Đăng xuất)" NavigateUrl="/Account/Logout" />
                                    </Items>
                                </ext:CompositeField>
                                <ext:FormPanel runat="server" ID="frmLogin" Url="/Account/Login" Border="false" BodyBorder="false"
                                    Layout="FormLayout" AutoHeight="true" AutoWidth="true" LabelWidth="70">
                                    <Items>
                                        <ext:TextField runat="server" ID="Username" FieldLabel="Tài khoản" LabelWidth="50"
                                            AllowBlank="false" />
                                    </Items>
                                </ext:FormPanel>
                            </div>
                            <div style="padding-left: 155px;">
                                <ext:Button ID="btnLogin" runat="server" Text="Đăng nhập">
                                    <Listeners>
                                        <Click Fn="CommonFunction.submitLogin" />
                                    </Listeners>
                                </ext:Button>
                            </div>
                            <div id="Mod1" class="moduletable_menu">
                                <div class="ja-box-ct">
                                    <ul class="menu">
                                        <ext:MenuPanel runat="server" ID="MainMenu" Header="false" Border="false" />
                                    </ul>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</body>
</html>
